<%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<%@ page import="com.ibm.ba.demo.entity.*" %>
<%@ page import="java.util.List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%! 
/**
 * Generate HTML table of recommended products.
 * 
 * @param .
 */
public String generateRecommendTable(BaDemoScoreResult result)
{	
	List<Product> products = result.getProducts();
	String output = 
		"<table id=\"RECOMMENDS_TABLE\">"+
			"<thead>"+
				"<tr>"+
					"<th style=\"width:50px\">ID</th>"+
					"<th style=\"width:200px\">Name</th>"+
					"<th style=\"width:50px\">Score</th>"+
				"</tr>"+
			"</thead>"+
			"<tfoot>"+
			"</tfoot>"+
			"<tbody>";

	for ( int i = 0 ; i < products.size() ; ++i ) {
		output += "<tr>";
		output += 		"<td>";
		output += 			String.valueOf(products.get(i).getProductId());
		output +=		"</td>";		
		output += 		"<td>";
		output += 			products.get(i).getProductName();
		output +=		"</td>";
		output += 		"<td>";
		output += 			products.get(i).getProductScore();
		output +=		"</td>";
		output += "</tr>";
	}
	
	output +=
			"</tbody>"+
		"</table>";
	return output;
}

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
</head>
<body>
	<%
		// Get recommended list
		BaDemoScoreResult result = (BaDemoScoreResult) request.getAttribute("scoreProds");
		if ( result == null )
			out.print("No data as recommended list.");
		else
			out.print(generateRecommendTable(result));
	%>
</body>
</html>